package edu.taru.controller;

import edu.taru.pojo.Menu;
import edu.taru.pojo.RoleMenu;
import edu.taru.service.MenuService;
import edu.taru.service.impl.MenuServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
public class MenuController {
    @Autowired
    MenuService menuService;
    @RequestMapping(value = "/menu/add")
    public String getMenuService(Menu menu) {
        menuService.addMenu(menu);
        return null;
    }
    @RequestMapping(value = "/menu/remove")
    public String getMenuService1(Integer menuId) {
        menuService.removeMenu(menuId);
        return null;
    }
    @RequestMapping(value = "/menu/update")
    public String getMenuService2(Menu menu) {
        menuService.updateMenu(menu);
        return null;
    }
    @RequestMapping(value = "/menu/query")
    public String getMenu(HttpSession session){
        List<Menu> menu=menuService.getMenu();
        session.setAttribute("menu",menu);
        return "RolewithMenu";
    }
    @RequestMapping(value = "/insert/RoleMenu")
    public  String insert(RoleMenu menu){
        menuService.addRoleMenu(menu);
        return "redirect:/select/Menu";
    }
}
